<template>
	<view>
		<view class="state_rq">
			<image src="https://aliyunoss.hntgov.net/h5/od_dfh.png"
				style="width: 96rpx;margin-left: 50rpx;height: 66rpx;" mode="widthFix"></image>
			<view
				style="display: flex;flex-direction: column;align-items: flex-start;justify-content: center;margin-left: 30rpx;">
				<text
					style="color: #fff;font-size: 32rpx;font-weight: bold;">{{info.orderStatus=='WAITPAY'?'待支付':info.orderStatus=='WAITSEND'?'待发货':info.orderStatus=='HAVESEND'?'已发货':info.orderStatus=='COMPLETED'?'已完成':info.orderStatus=='CANCELLED'?'已取消':''}}</text>
				<text style="color: #fff;font-size: 28rpx;"
					v-if="info.orderStatus=='COMPLETED'">卡号会在10分钟左右以短信的形式发放</text>
			</view>
		</view>

		<view style="position: absolute;top: 352rpx;">
			<view class="or_iiii">
				<view class="oo_iii">购物清单</view>
				<view class="oo_ii">
					<image class="oo_ii_image" :src="info.orderPic||'https://aliyunoss.hntgov.net/sd/all_moren.png'">
					</image>
					<view class="oo_ii_view">
						{{info.orderName||''}}
					</view>
					<text
						style="color: #3D3D3D;position: absolute;top: 0rpx;right: 0rpx;font-size: 32rpx;">￥{{(info.goodsAmount/100).toFixed(2)}}</text>
					<text
						style="color: #AFA9A9;position: absolute;top: 86rpx;left: 148rpx;font-size: 24rpx;">电子卡（我已阅读使用须知）</text>
					<text
						style="color: #AFA9A9;position: absolute;top: 86rpx;right:0rpx;font-size: 24rpx;">x{{info.buyNum||1}}</text>
					<view style="position: absolute;right: 0rpx;bottom: 30rpx;">
						<u-tag text="去支付" @click="toPay(info)" v-if="info.orderStatus=='WAITPAY'" type="primary"
							shape='circle' color='#a0cfff' style="width: 120rpx;text-align: center;" />
					</view>
				</view>
			</view>

			<view class="or_iiii" style="margin-top: 30rpx;">
				<view class="oo_iii">订单详情</view>
				<view class="oo_item">
					<text style="color: #696969;">订单编号：</text>
					<text style="color: #3D3D3D;position: absolute;right: 0rpx;">{{info.orderId||''}}</text>
				</view>
				<view class="oo_item">
					<text style="color: #696969;">购买时间：</text>
					<text style="color: #3D3D3D;position: absolute;right: 0rpx;">{{info.orderTime||''}}</text>
				</view>
				<view class="oo_item">
					<text style="color: #696969;">购买数量：</text>
					<text style="color: #3D3D3D;position: absolute;right: 0rpx;">{{info.buyNum||''}}</text>
				</view>
				<view class="oo_item" style="padding-bottom: 30rpx;">
					<text style="color: #696969;">支付金额：</text>
					<text
						style="color: #3D3D3D;position: absolute;right: 0rpx;">¥{{(info.payableAmount/100).toFixed(2)||''}}</text>
				</view>
			</view>
			<!-- 购买10分钟后自动发货 -->

			<view class="or_iiii" style="margin-top: 30rpx;padding-bottom: 80rpx;">
				<view class="oo_iii">卡号详情</view>
				<view v-if="!info.cardNum" style="margin-top: 30rpx;margin-left: 30rpx;color: #f00;">支付后可在此处查看卡号</view>
				<view v-else>
					<view class="oo_item" v-for="(item,index) in cardNumList" :key="index">
						<text style="color: #696969;">卡号（{{index+1}}）：{{item}}</text>
						<view style="position: absolute;right: 0rpx;">
							<u-button type="primary" size='mini' @click="copyCardNum(item)">复制</u-button>
						</view>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	var that = ''
	export default {
		data() {
			return {
				id: '',
				info: '',
				cardNumList: [],
				orderId: ''
			}
		},
		onLoad(e) {
			that = this
			this.orderId = e.id
		},
		onShow() {
			if(!uni.getStorageSync('phone')){
				uni.navigateTo({
					url:'/pages/index/authorization'
				})
			}else{
				this.getOrderUrlMethod()
			}
			
		},
		onReady() {
			uni.setNavigationBarTitle({
				title: '订单详情'
			})
		},
		methods: {
			getOrderUrlMethod(){
				that.$u.api.getOrderUrl({
					orderId: this.orderId
				}).then(res => {
					if (res) {
						this.info=res.data
						if (this.info.cardNum) {
							this.cardNumList = this.info.cardNum.split(',')
						}
					}
				})
			},
			toPay(e) {
				that.$u.api.getPrepayUrl({
					openId: uni.getStorageSync('openId'),
					orderNo: e.orderId,
					amount: e.buyNum,
					description: ''
				}).then(result => {
					if (result) {
						uni.requestPayment({
							provider: 'alipay',
							tradeNO: result.data.outTradeNo,
							success: function(res1) {
								console.log(res1);
								if (res1.resultCode == '9000') {
									uni.navigateBack()
								}
							},
							fail: function(err) {
								console.log(err);
							}
						})
					}
				})
			},
			toSfType() {
				uni.navigateTo({
					url: '/pages/order/sftype?id=' + this.id
				})
			},
			copyCardNum(e) {
				uni.setClipboardData({
					data: e,
					success() {
						uni.showToast({
							title: '复制成功'
						})
					}
				})
			}
		}
	}
</script>
<style>
	page {
		background: #f7f7f7;
	}

	.state_rq {
		border-radius: 0% 0% 100% 100% / 33% 33% 7% 7%;
	}
</style>
<style lang="less" scoped>
	.oo_item {
		width: 630rpx;
		margin-left: 30rpx;
		position: relative;
		align-items: center;
		display: flex;
		margin-top: 30rpx;
	}

	.or_iiii {
		width: 690rpx;
		border-radius: 8rpx;
		background-color: #fff;
		margin-left: 30rpx;

		.oo_iii {
			width: 630rpx;
			margin-left: 20rpx;
			height: 82rpx;
			border-bottom: 2rpx #E7E6E6 solid;
			color: #3D3D3D;
			font-size: 28rpx;
			padding-left: 10rpx;
			line-height: 82rpx;


		}
	}

	.oo_ii {
		width: 630rpx;
		height: 240rpx;
		margin-top: 20rpx;
		margin-left: 30rpx;
		display: flex;
		position: relative;


	}

	.oo_ii_view {
		width: 334rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: -o-ellipsis-lastline;
		max-height: 4em;
		/* 2行文本的高度 */
		line-height: 1.5em;
		/* 行高 */
		height: 3em;
		/* 高度为行高的两倍 */
		margin-left: 20rpx;
	}

	.oo_ii_image {
		width: 128rpx;
		height: 128rpx;
		border-radius: 8rpx;
	}

	.state_rq {
		width: 750rpx;
		height: 452rpx;
		display: flex;
		align-items: center;
		background: #3278E7;
	}
</style>